<?php
	namespace Common\Logic;
	use Common\Model\MemberRoleUserModel;
	class MemberRoleUserLogic extends MemberRoleUserModel{
		/*
		* Function:		getMemberRoleUserList
		* Description:	角色用户关系表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getMemberRoleUserList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getMemberRoleUserFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getMemberRoleUserFilter
		* Description:	用户列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getMemberRoleUserFilter($filter = ''){
			$conditon = array();
			if(!empty($filter['login_name'])){
				$conditon['login_name'] = $filter['login_name'];
			}
			if(!empty($filter['real_name'])){
				$conditon['real_name'] = array('like',$filter['real_name'].'%');
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getMemberRoleUserCount
		* Description:	用户列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getMemberRoleUserCount($filter = ''){
			$conditon = $this->getMemberRoleUserFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addMemberRoleUser
		* Description:	增加用户
		* @param:		$data array 增加的数组
		*/
		public function addMemberRoleUser($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getMemberRoleUserInfo
		* Description:	获取用户列表信息 by row
		* @param:		$id int ID
		*/
		public function getMemberRoleUserInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateMemberRoleUser
		* Description:	更新用户
		* @param:		$data array 更新的数组
		*/
		public function updateMemberRoleUser($data){
			return $this->save($data);
		}
	}
?>